package crmdna.interaction;

import java.util.Date;

import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;

@Entity
@Cache
public class InteractionEntity {
	@Id
	long ns; // get current time in milliseconds. add a random no between 0 to 1
				// million to convert to nanoseconds. This way we save on one
				// indexed field for date

	String interaction;
	@Index
	String interactionType;

	@Index
	long userId;

	String userEmail; // user's email id

	@Index
	long memberId;

	public InteractionProp toProp() {
		InteractionProp interactionProp = new InteractionProp();

		// convert nano seconds to milliseconds
		long ms = ns / 1000000;

		interactionProp.ns = ns;
		interactionProp.timestamp = new Date(ms);
		interactionProp.interaction = interaction;
		interactionProp.interactionType = interactionType;
		interactionProp.userId = userId;
		interactionProp.memberId = memberId;

		return interactionProp;
	}
}
